home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_13_06 / vancamp / tbldata.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  1995-02-02  |  1.4 KB  |  62 lines

  1. // tbldata.hpp: TableData class (LISTING 1)
  2. #ifndef TBLDATA_HPP
  3. #define TBLDATA_HPP
  4. #include <string.h>
  5. #include <assert.h>
  6.  
  7. template <class cellType> class TableData
  8. {
  9. public:
  10.     TableData (TableData *const prev):
  11.             PrevTD (prev)
  12.     { }
  13.     virtual ~TableData (void)
  14.     { }
  15.  
  16.     virtual const cellType GetCell (const int row,
  17.             const int col)
  18.     {
  19.         assert (PrevTD != 0); // Override in buffer
  20.         return (PrevTD->GetCell (row, col));
  21.     }
  22.  
  23.     virtual void PutCell (const int row, const int col,
  24.             const cellType &value)
  25.     {
  26.         assert (PrevTD != 0);
  27.         PrevTD->PutCell (row, col, value);
  28.     }
  29.  
  30.     virtual const int GetNumRows (void) const
  31.     {
  32.         assert (PrevTD != 0);
  33.         return (PrevTD->GetNumRows ());
  34.     }
  35.  
  36.     virtual const int GetNumCols (void) const
  37.     {
  38.         assert (PrevTD != 0);
  39.         return (PrevTD->GetNumCols ());
  40.     }
  41.  
  42.     virtual const char &GetRowHeading (const int row)
  43.     {
  44.         assert (PrevTD != 0);
  45.         return (PrevTD->GetRowHeading (row));
  46.     }
  47.  
  48.     virtual const char &GetColHeading (const int col)
  49.     {
  50.         assert (PrevTD != 0);
  51.         return (PrevTD->GetColHeading (col));
  52.     }
  53.  
  54. protected:
  55.     TableData *PrevTD;  // ptr to prev link in chain
  56. private:
  57.     TableData (void);   // disable default methods
  58.     TableData (const TableData &tData);
  59.     TableData& operator= (const TableData&);
  60. };
  61. #endif
  62.